<?php
declare (strict_types = 1);

namespace app\common\validate\Post;

use think\Validate;

class Post extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'title' => 'require',
        'content' => 'require',
        'point' => 'require|egt:0',
        'state' => 'in:0,1,2,3',  //从某个范围来选择
        'userid' => 'require',
        'cateid' => 'require'
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'title.require' => '帖子标题必填',
        'content.require' => '帖子内容必填',
        'point.require' => '悬赏积分必填',
        'point.egt' => '悬赏积分不能小于0',
        'state.in' => '帖子的状态未知',
        'userid.require' => '发帖人未知',
        'cateid.require' => '请选择分类',
    ];
    
    protected $scene = [
        'edit'  =>  ['title','content','cateid'],
    ];
}
